<template>
	<view class="lineWarp">
		<view style="background: #fff; padding-top: 10upx; border-radius: 16upx;">
			<RouterItem
				v-for="(router, tager) in lineList"
				:key="router.id"
				:fromCity="router.fromCity || ''"
				:endCity="router.endCity || ''"
				:ticketPrice="router.ticketPrice"
				@toTickets="toTickets(router)"
			/>
		</view>
		
	</view>
</template>

<script>
	import api from '../../api';
	import RouterItem from '../index/components/RouterItem.vue';
	export default {
		components: {
			RouterItem
		},
		data() {
			return {
				lineList:[]
			}
		},
		
		onPullDownRefresh() {
			this.getAllRoute()
		},
		
		onLoad(option) {
			uni.startPullDownRefresh();
		},
		methods: {
			toTickets(data) {
				uni.navigateTo({
					url: `../buyTickets/buyTickets?router=${JSON.stringify(data)}`
				})
				
			},
			getAllRoute(){
				api.route.getAllRoute().then(res=>{
					if(res.code == 200){
						this.lineList = res.data
					}
				}).finally(res=>{
					uni.stopPullDownRefresh();  //停止下拉刷新动画
				})
			},
		}
	}
</script>

<style lang="scss">
	.lineWarp {
		height: 100%;
		background: #F7F7F7;
		padding: 20upx;
	}
</style>
